package com.itheima.reggie.mapper;

import com.itheima.reggie.dto.DishDto;
import com.itheima.reggie.entity.Dish;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface DishDtoMapper {

    /**
     * 添加菜品
     * @param
     * @return
     */
    @Insert("insert into dish(id,name,category_id,price,code,image,description,status,sort,create_time,update_time,create_user,update_user,is_deleted)" +
            " values (null,#{name},#{categoryId},#{price},#{code},#{image},#{description},#{status},#{sort},#{createTime},#{updateTime},#{createUser},#{updateUser},0)")
    Integer addDish(DishDto dishDto);

    /**
     * 根据菜品名字查找菜品：判断菜品名字是否重复
     * @param
     * @return
     */
    Dish selectByName(String name);

    /**
     * 根据菜品名字查找所有菜品
     * @param name
     * @return
     */
//    @Select("select * from dish where name=#{name}")
    List<DishDto> findAllByName(String name);

    /**
     * 根据Id查找菜品名字
     * @param name
     * @return
     */
    @Select("select name from dish where id=#{id}")
    String findNameById(Long name);


    /**
     * 根据查找菜品
     * @param id
     * @return
     */
    @Select("select * from dish where id=#{id}")
    DishDto findDishDtoById(Long id);

    /**
     * 菜品修改
     * @param dishDto
     * @return
     */
    Integer updateDishDto(DishDto dishDto);


    /**
     * 批量删除
     * @param ids
     * @return
     */
    Integer DeleteByIds(Long[] ids);

    /**
     * 批量启用
     * @param ids
     * @return
     */
    Integer use(Long[] ids);
    /**
     * 批量禁用
     * @param ids
     * @return
     */
    Integer unUse(Long[] ids);

    /**
     * 根据菜品分类id查找菜品
     * @param categoryId
     * @return
     */
    @Select("select * from dish where category_id=#{categoryId} and status=#{status} ")
    List<DishDto> findDishDtoByCategoryId(Long categoryId,Integer status);


}
